package com.jy.api.config;

import org.springframework.http.HttpStatus;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.HttpStatusReturningLogoutSuccessHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by hanxi on 2018/9/25.
 */
public class LogoutSuccessHandler extends HttpStatusReturningLogoutSuccessHandler {
    @Override
    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
        response.setStatus(HttpStatus.OK.value());
        response.setHeader("access-control-allow-credentials", "true");
        response.setHeader("access-control-allow-origin", request.getHeader("origin"));
        response.getWriter().flush();
    }
}
